#!/bin/bash
#SBATCH --nodes=1
#SBATCH --partition=wzhdtest
#SBATCH --ntasks-per-node=32
#SBATCH --time=24:00:00
#SBATCH --job-name=prepare_systems
#SBATCH -e log/prepare_systems-%j.out
#SBATCH -o log/prepare_systems-%j.out

source ~/.bashrc
source /work/home/aixplorerbio_wz/miniconda3/bin/activate amber
source /work/home/aixplorerbio_wz/software/gromacs-2020.3/bin/GMXRC

module switch compiler/dtk/21.10
module load apps/Gromacs-DCU2/2020.3/hpcx-gcc-7.3.1

if [ $# != 1 ]; then
    echo "USAGE: $0 $PROJECT_HOME"
    echo " e.g.: $0 ../"
    exit 1
fi

pwd=$(pwd)
PROJECT_HOME=$(cd $1 && pwd)
WORK_PATH=$PROJECT_HOME/work_dir/job
ligands_path=$WORK_PATH/ligands

rm -rf $WORK_PATH
mkdir -p $ligands_path

cp -r $PROJECT_HOME/mdp $WORK_PATH
cp $PROJECT_HOME/work_dir/sdf/* $ligands_path
cp -r $PROJECT_HOME/work_dir/md/* $ligands_path

cd $WORK_PATH

cp $PROJECT_HOME/protein.pdb .
python $PROJECT_HOME/prepare_solvated_sys.py -lig_dir_path ligands -lig_extension .sdf -protein_pdb protein.pdb
